Skip to main content

Case sensitivity in JavaScript

JavaScript is case sensitivity. Which means if you name a variable result and other Result, each variable refers to a separate, distinct variable.

Work out

var result = [1, 2, 3, 4];
var Result = [5, 6, 7, 8];
console.log("result = " + result);
// expected output: result = [1, 2, 3, 4]
console.log("Result = " + Result);
// expected output: Result = [5, 6, 7, 8]

Example

function sum(a, b) {
return a + b;
}
function Sum(a, b) {
return a + b;
}
console.log(sum(2, 5));
// expected output: 7
console.log(Sum(5, 18));
// expected output: 23
Note

Case sensitivity is applicable to all aspects of the language including keywords, operators, object properties, and so on.

Danger

All javascipt statements requires lower case, for example if statement. Make sure to type if, not If or iF.